<script setup>
import { RouterLink } from 'vue-router'
import { ref } from 'vue'

const bookImage = [
  new URL('@/assets/images/book-1.png', import.meta.url).href,
  new URL('@/assets/images/book-2.png', import.meta.url).href,
  new URL('@/assets/images/book-3.png', import.meta.url).href,
  new URL('@/assets/images/book-4.png', import.meta.url).href,
  new URL('@/assets/images/book-5.png', import.meta.url).href,
  new URL('@/assets/images/book-6.png', import.meta.url).href,
  new URL('@/assets/images/book-7.png', import.meta.url).href,
  new URL('@/assets/images/book-8.png', import.meta.url).href,
  new URL('@/assets/images/book-9.png', import.meta.url).href,
  new URL('@/assets/images/book-10.png', import.meta.url).href,
]
const category_list = ['文学小说', '生活', '文艺', '人文社科', '科技', '少儿教育', '音响/期刊']
const press_list = [
  '人民文学出版社',
  '新华书店',
  '中华书局',
  '人民出版社',
  '清华大学出版社',
  '北京大学出版社',
  '高等教育出版社',
]
const options_list = ['综合', '销量 ', '价格', '新品']
const moreoption_list = ['百亿补贴', '国家补贴', '显示有货', '货到付款', '二手', '加急配送']

// 高亮状态ref
const activeCategory = ref(0)
const activePress = ref(-1)
const activeOption = ref(0)

// 更多选项多选
const checkedMoreOptions = ref([])
</script>

<template>
  <div class="selective-page">
    <!--导航栏-->
    <div class="selective-page-navbar">
      <div class="selective-page-navbar-wrapper">
        <h1 class="selective-page-navbar-wrapper-title-left">全部分类</h1>
        <h1 class="selective-page-navbar-wrapper-title-right">
          <router-link to="/">首页</router-link>
        </h1>
      </div>
      <div class="selective-page-navbar-wrapper-divider"></div>
    </div>

    <!--筛选器-->
    <div class="selective-page-filtrate">
      <div class="selective-page-filtrate-category">
        <div class="selective-page-filtrate-category-title">分类</div>
        <ul class="selective-page-filtrate-category-list">
          <li
            v-for="(item, index) in category_list"
            :key="index"
            :class="{ active: activeCategory === index }"
            @click="activeCategory = index"
          >
            {{ item }}
          </li>
        </ul>
        <div class="selective-page-filtrate-category-actions">
          <button class="selective-page-filtrate-category-actions-more-btn">更多</button>
          <button class="selective-page-filtrate-category-actions-multi-btn">+多选</button>
        </div>
      </div>
      <div class="selective-page-filtrate-press">
        <div class="selective-page-filtrate-press-title">排序</div>
        <ul class="selective-page-filtrate-press-list">
          <li
            v-for="(item, index) in press_list"
            :key="index"
            :class="{ active: activePress === index }"
            @click="activePress = index"
          >
            {{ item }}
          </li>
        </ul>
      </div>
      <div class="selective-page-filtrate-options">
        <div class="selective-page-filtrate-options-title">筛选</div>
        <ul class="selective-page-filtrate-options-list">
          <li
            v-for="(item, index) in options_list"
            :key="index"
            :class="{ active: activeOption === index }"
            @click="activeOption = index"
          >
            {{ item }}
          </li>
        </ul>
      </div>
      <div class="selective-page-filtrate-moreoption">
        <div class="selective-page-filtrate-moreoption-title">更多选项</div>
        <ul class="selective-page-filtrate-moreoption-list">
          <li v-for="(item, index) in moreoption_list" :key="index">
            <el-checkbox v-model="checkedMoreOptions" :label="item" style="color: #222" />
          </li>
        </ul>
      </div>
    </div>

    <!--书单选购-->
    <div class="selective-page-commdity">
      <div class="selective-page-commdity-item" v-for="(img, index) in bookImage" :key="index">
        <img :src="img" alt="" />
        <div class="selective-page-commdity-item-info">
          <router-link to="/commoditydetail" style="text-decoration: none">
            <div class="selective-page-commdity-item-info-title">测试样例-书本</div>
            <div class="selective-page-commdity-item-info-desc">测试样例-书本介绍</div>
            <div class="selective-page-commdity-item-info-price">￥19.99</div>
            <div class="selective-page-commdity-item-info-saledata">
              <div class="selective-page-commdity-item-info-order">
                <div class="selective-page-commdity-item-info-order-amount">10+</div>
                <div class="selective-page-commdity-item-info-order-text">购买</div>
              </div>
              <div class="selective-page-commdity-item-info-evaluate">
                <div class="selective-page-commdity-item-info-evaluate-amount">1000+</div>
                <div class="selective-page-commdity-item-info-evaluate-text">评价</div>
              </div>
              <div class="selective-page-commdity-item-info-reputation">
                <div class="selective-page-commdity-item-info-reputation-amount">99%</div>
                <div class="selective-page-commdity-item-info-reputation-text">好评</div>
              </div>
            </div>
          </router-link>
        </div>
      </div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.selective-page {
  width: 100%;
  height: 700px;
  overflow-x: hidden;
  background: #f7f7f7;
  .selective-page-navbar {
    width: 100%;
    padding: 20px 0;
    .selective-page-navbar-wrapper {
      width: 80%;
      display: flex;
      margin: 0 auto;
      justify-content: space-between;
    }
    .selective-page-navbar-wrapper-title-left,
    .selective-page-navbar-wrapper-title-right {
      font-size: 24px;
      font-weight: 600;
      color: #222;
    }
    .selective-page-navbar-wrapper-title-right a {
      color: #222;
      text-decoration: none;
      transition: 0.2s;
      font-weight: 600;
      &:hover {
        color: #ff9800;
      }
    }
    .selective-page-navbar-wrapper-divider {
      width: 80%;
      height: 1px;
      background-color: #e0e0e0;
      margin: 20px auto;
      border: none;
    }
  }
  .selective-page-filtrate {
    width: 80%;
    height: 250px;
    background: #fff;
    margin: 0 auto;
    border-radius: 20px;
    .selective-page-filtrate-category,
    .selective-page-filtrate-press,
    .selective-page-filtrate-options,
    .selective-page-filtrate-moreoption {
      width: 93%;
      display: flex;
      align-items: center;
      padding: 30px 0 0 30px;
      .selective-page-filtrate-category-title,
      .selective-page-filtrate-press-title,
      .selective-page-filtrate-options-title,
      .selective-page-filtrate-moreoption-title {
        color: #888;
        font-size: 18px;
        font-family: 'Courier New', Courier, monospace;
        margin-right: 10px;
        text-align: right;
        font-weight: 550;
      }
      .selective-page-filtrate-category-list,
      .selective-page-filtrate-press-list,
      .selective-page-filtrate-options-list,
      .selective-page-filtrate-moreoption-list {
        font-weight: 550;
        margin-left: 30px;
        display: flex;
        flex-wrap: wrap;
        gap: 25px;
        flex: 1;
        li {
          color: #222;
          cursor: pointer;
          transition: color 0.2s;
          list-style: none;
          font-family: 'Courier New', Courier, monospace;
          &:hover {
            color: #ff9800;
          }
          &.active {
            color: #ff9800;
            background: #fff;
          }
        }
      }
      .selective-page-filtrate-category-actions {
        display: flex;
        gap: 5px;
        margin-left: 10px;
        .selective-page-filtrate-category-actions-more-btn,
        .selective-page-filtrate-category-actions-multi-btn {
          border: 1px solid #ccc;
          background: #fff;
          color: #333;
          padding: 2px 8px;
          border-radius: 2px;
          font-size: 14px;
          cursor: pointer;
          transition:
            border 0.2s,
            color 0.2s;
          &:hover {
            border-color: #1976d2;
            color: #1976d2;
          }
        }
      }
    }
  }
  .selective-page-commdity {
    width: 80%;
    height: 100%;
    margin: 20px auto;
    display: flex;
    flex-wrap: wrap;
    gap: 24px 18px;
    justify-content: flex-start;
    justify-content: space-between;
    .selective-page-commdity-item {
      width: 225px;
      height: 320px;
      border-radius: 12px;
      transition: all 0.3s linear;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: flex-start;
      cursor: pointer;
      background: #fff;
      &:hover {
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.13);
        background: #fff;
      }
      img {
        width: 150px;
        height: 180px;
        object-fit: cover;
        border-radius: 8px;
        margin-top: 15px;
        background: #fff;
        &:hover {
          background: #fff;
        }
      }
      .selective-page-commdity-item-info {
        width: 100%;
        padding: 10px 0 0 10px;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        margin-left: 20px;
        .selective-page-commdity-item-info-title {
          font-size: 18px;
          font-weight: 550;
          color: #222;
        }
        .selective-page-commdity-item-info-desc {
          font-size: 14px;
          font-weight: 500;
          color: #888;
          margin-bottom: 10px;
        }
        .selective-page-commdity-item-info-price {
          font-size: 14px;
          font-weight: bold;
          color: #222;
          margin-bottom: 20px;
        }
        .selective-page-commdity-item-info-saledata {
          display: flex;
          width: 100%;
          flex-wrap: wrap;
          gap: 10px 16px;
          justify-content: flex-start;
        }
        .selective-page-commdity-item-info-order,
        .selective-page-commdity-item-info-evaluate,
        .selective-page-commdity-item-info-reputation {
          font-size: 12px;
          color: #00000080;
          display: flex;
          align-items: center;
        }
      }
    }
  }
}

.selective-page-filtrate-category-list li.active,
.selective-page-filtrate-press-list li.active,
.selective-page-filtrate-options-list li.active {
  color: #ff9800;
  border-color: #ff9800;
  background: #fff7e6;
}

.el-checkbox__input.is-checked + .el-checkbox__label {
  color: #ff9800;
}
</style>
